package gwtappcontainer.testhelpers;
import gwtappcontainer.server.apis.admin.GateKeeper;
import gwtappcontainer.server.apis.admin.Roles.Role;
import gwtappcontainer.shared.apis.admin.RoleProp;
import gwtappcontainer.shared.apis.admin.UserProp;
import java.util.ArrayList;
import java.util.HashMap;
import com.google.appengine.api.users.User;
public class MockGateKeeper extends GateKeeper {
HashMap<String, UserProp> userProps = new HashMap<String, UserProp>();
public void allowRoleToUser(String email, Role role) {
email = email.toLowerCase();
RoleProp roleProp = new RoleProp();
roleProp.name = role.toString();
UserProp userProp;
if (userProps.containsKey(email)) {
userProp = userProps.get(email);
} else {
userProp = new UserProp();
userProp.roles = new ArrayList<RoleProp>();
userProp.email = email;
userProps.put(email, userProp);
}
userProp.roles.add(roleProp);
}
@Override
protected UserProp getUserProp(User user) {
UserProp prop = userProps.get(user.getEmail().toLowerCase());
return prop;
}
}